import React from "react";
import { CommonField } from "@/pages/OrderModule/common/components/CommonForm";
// import CommonInputNumber from "@/pages/OrderModule/common/components/CommonInputNumber";
import {
	Col,
	Form,
	// Input, Select,
	Row
} from "antd";
import {
	PrefixPlaceholder,
	Input,
	Select,
	PreInputNumber,
	CommonInput,
	CommonInputNumber
} from "@/views/components/PrefixPlaceholder";
import Style from "./index.module.less";
export default function Formlist({ name, initialValue }) {
	return (
		<Form.List name={name} initialValue={initialValue}>
			{(fields, { add, remove }) => (
				<div className={Style.container}>
					{fields.map(({ key, name, ...restField }, index, arr) => {
						const item = initialValue[index];
						return item?.status ? (
							// <div key={key} span={8}>
							<Form.Item
								key={name}
								{...restField}
								//name采用数组方式，第一个元素name可理解为行号，first为字段名
								//行号+字段名联合才能定位列表行字段
								name={[name, "value"]}
								className={Style.item}
							>
								{
									item.attributeName == "市场价I吊牌价" ? (
										<CommonInputNumber placeholder="市场价I吊牌价" min={0} precision={2} controls={false} />
									) : item.type == 1 ? (
										<Select options={item?.options || []} placeholder={`${item?.attributeName ?? ""}`} />
									) : (
										<Input placeholder={`${item?.attributeName ?? ""}`} />
									)
									// <CommonField
									// 	Component={item?.type == 1 ? Select : Input}
									// 	key={name}
									// 	props={{
									// 		placeholder: `${item?.attributeName ?? ""}`,
									// 		options: item?.options || []
									// 	}}
									// />
								}
							</Form.Item>
						) : (
							// </div>
							<></>
						);
					})}
				</div>
			)}
		</Form.List>
	);
}
